SUBROUTINE TABLE_S4
     * Create a simple table using the RWS_TABLE routines and
     * populate it with data from a Reality file. Draw borders
     * round the cells. Right align the columns.

     * Include the RealWeb definitions.
     INCLUDE #RW.INCLUDE.DEFS FROM /SYSFILES/REALWEB,BP

     EQU LF TO CHAR(10)
     EQU TAB TO CHAR(9)
     EQU AM TO CHAR(254)
     EQU VM TO CHAR(253)

     * Get the URL of the Reality item server.
     STYLESHEET = ""
     CALL RW_GET_PARAM("__isurl", STYLESHEET)
     * Specify the location of the stylesheet.
     STYLESHEET = STYLESHEET : "/REALWEB-ITEMS/blue.css"

     * Start the HTML page.
     CALL RW_START_HTML_PAGE("RWS_Table with Reality Data Example 3", "", STYLESHEET, "", "")

     * Initialise the HTML string buffer.
     HTML = ""

     * Create a caption for the table.
     TEXT = "Hotel Guests"
     CALL RWS_TABLE_CAPTION(TEXT, "")
     HTML = HTML : TEXT

     * Assemble some data to go in the table.
     PERFORM "SORT-SPREAD GUESTS < '200' " : ...
        "ROOM NAME ADDRESS CITY STATE ZIP ID-SUPP" ...
        CAPTURING aData
     *   The headings are in the second attribute.
     DEL aData<1>
     aHeadings = aData<1>
     *   SORT-SPREAD returns tab-separated data; we need a dynamic array.
     aHeadings = CHANGE(aHeadings, TAB, AM)
     *   The data is in the third attribute onwards.
     DEL aData<1>
     *   SORT-SPREAD returns tab-separated data; we need a dynamic array.
     aData = CHANGE(aData, TAB, VM)

     * For each heading...
     FOR I = 1 TO DCOUNT(aHeadings , AM)
        * Tag the text as a heading cell.
        S = aHeadings<I>
        CALL RWS_TABLE_HEADER(S, "")
        aHeadings<I> = S
     NEXT I
     * Tag the attribute as a table row.
     CALL RWS_TABLE_ROW(aHeadings, "")
     HTML = HTML : aHeadings

     * For each data attribute...
     FOR I = 1 TO DCOUNT(aData, AM)
        * For each value in the attribute...
        FOR J = 1 TO DCOUNT(aData<I>, VM)
           * Right align the columns.
           aClass = ""
           aClass<2> = "RIGHT"
           * Tag the text as a table cell.
           S = aData<I,J>
           CALL RWS_TABLE_DATA(S, aClass)
           aData<I,J> = S
        NEXT J
        * Tag the attribute as a table row.
        S = aData<I>
        CALL RWS_TABLE_ROW(S, "")
        aData<I> = S
     NEXT I
     HTML = HTML : aData

     * Give the table a 5 pixel border.
     aClass = ""
     aClass<2> = "5"
     * Make the internal rules 2 pixels wide.
     aClass<3> = "2"
     * Give the table a background colour.
     aClass<4> = "cellspacing=0 cellpadding=5 bgcolor=lightsteelblue"

     * Create the table.
     CALL RWS_TABLE(HTML, aClass)

     * Output the HTML.
     HTML = CONVERT(HTML, AM:VM, LF:TAB)
     CALL RW_PUT(HTML)

     * Complete the page.
     CALL RW_END_PAGE
RETURN

Go to top button